<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>农历黄历测试</title>
    <script src="https://unpkg.com/lunar-javascript@1.6.12/dist/lunar.min.js"></script>
</head>
<body>
    <h1>农历黄历测试</h1>
    <div id="result"></div>
    
    <script>
        try {
            console.log('开始测试 lunar-javascript 库');
            
            // 获取当前日期
            const now = new Date();
            const year = now.getFullYear();
            const month = now.getMonth() + 1;
            const day = now.getDate();
            
            console.log('当前日期:', year, month, day);
            
            // 创建阳历日期对象
            const solar = Lunar.Solar.fromYmd(year, month, day);
            const lunar = solar.getLunar();
            
            console.log('Solar:', solar.toString());
            console.log('Lunar:', lunar.toString());
            
            // 获取农历信息
            const lunarMonthChinese = lunar.getMonthInChinese();
            const lunarDayChinese = lunar.getDayInChinese();
            const yearGanZhi = lunar.getYearInGanZhi();
            const dayGanZhi = lunar.getDayInGanZhi();
            
            // 获取宜忌
            const yiList = lunar.getDayYi();
            const jiList = lunar.getDayJi();
            
            console.log('农历:', lunarMonthChinese, lunarDayChinese);
            console.log('干支:', yearGanZhi, dayGanZhi);
            console.log('宜:', yiList);
            console.log('忌:', jiList);
            
            // 显示结果
            const resultDiv = document.getElementById('result');
            resultDiv.innerHTML = `
                <p><strong>农历日期:</strong> ${lunarMonthChinese}${lunarDayChinese}</p>
                <p><strong>干支纪年:</strong> ${yearGanZhi}年 ${dayGanZhi}日</p>
                <p><strong>宜:</strong> ${Array.isArray(yiList) && yiList.length > 0 ? yiList.slice(0, 3).join(', ') : '诸事不宜'}</p>
                <p><strong>忌:</strong> ${Array.isArray(jiList) && jiList.length > 0 ? jiList.slice(0, 3).join(', ') : '无特别禁忌'}</p>
            `;
            
        } catch (error) {
            console.error('测试失败:', error);
            document.getElementById('result').innerHTML = `<p style="color: red;">测试失败: ${error.message}</p>`;
        }
    </script>
</body>
</html>